﻿<!-- #include file="../Include/Admin_Onlogin.asp" -->
<%
Data_Name = "{prefix}Count"
strFileName = "Admin_Count.asp"
Dim sqlAuth, rsAuth, PurviewID
sqlAuth = "Select AuthID From Admin_Auth Where href='Admin/" & strFileName & "' Order By sort Asc,AuthID Asc"
Call Exec(rsAuth,sqlAuth,2)
If rsAuth.BOF And rsAuth.EOF Then
	PurviewID = 0
Else
	PurviewID = rsAuth(0)
	CheckPurview PurviewID,0
End If
rsAuth.Close
Set rsAuth = Nothing
Select Case Action
Case "SaveModify"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='Count/Update' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
	Call SaveModify()
Case Else
	Call Main()
End Select
If FoundErr = True Then
	Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Call CloseConn()

Sub Main()
	Response.Write "<!DOCTYPE html>" & vbCrLf
	Response.Write "<head>" & vbCrLf
	Response.Write "<title>统计管理</title>" & vbCrlf
	Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
	Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
	Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
	Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
	Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/global.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/font.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<script type='text/javascript'>" & vbCrLf
	Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
	Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/xm-select/xm-select.js""></script>" & vbCrLf
	Response.Write "</head>" & vbCrlf
	Response.Write "<body>" & vbCrlf
	Response.Write "<script language=javascript>" & vbCrlf
	Response.Write "function IsDigit(cCheck)" & vbCrlf
	Response.Write "{" & vbCrlf
	Response.Write "return (('0'<=cCheck) && (cCheck<='9'));" & vbCrlf
	Response.Write "}" & vbCrlf
	Response.Write "function checkInput(nForm) {" & vbCrlf
	Response.Write "var my_str=nForm.Hits.value;" & vbCrlf
	Response.Write "for(var i=0;i<my_str.length;i++){" & vbCrlf
	Response.Write "var c=my_str.charAt(i);" & vbCrlf
	Response.Write "if(c<""0""||c>""9""){" & vbCrlf
	Response.Write "IsAlertFocus(""计数器应为数字,请填写正确的内容!"",""Hits"");" & vbCrlf
	Response.Write "nForm.Hits.select();" & vbCrlf
	Response.Write "return false;" & vbCrlf
	Response.Write "}" & vbCrlf
	Response.Write "}" & vbCrlf
	Response.Write "return true;" & vbCrlf
	Response.Write "}" & vbCrlf
	Response.Write "</script>" & vbCrlf
	sqlCountList="Select * From ["&Data_Name&"] Where ID=1"
	Call Exe_Conn(rsCountList,sqlCountList,1)
	If rsCountList.BOF And rsCountList.EOF Then
		rsCountList.Close
		Set rsCountList = Nothing
		Response.Write "没有任何数据！"
		Exit Sub
	End If
	Response.Write "<form class='layui-form layui-form-pane' id=""myform"" name=""myform"" action='?Action=SaveModify' method=""post"">" & vbCrlf
	Response.Write "<div class=""admin-main fadeInUp animated"">" & vbCrlf
	Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrlf
	Response.Write "        <legend>统计管理</legend>" & vbCrlf
	Response.Write "    </fieldset>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">计数器样式</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-5"">" & vbCrlf
	j=0:n=0
	MaxPerPage = 5
	totalPut = 55
	If CurrentPage < 1 Then
		CurrentPage = 1
	End If
	If (CurrentPage - 1) * MaxPerPage > totalPut Then
		If (totalPut Mod MaxPerPage) = 0 Then
			CurrentPage = totalPut \ MaxPerPage
		Else
			CurrentPage = totalPut \ MaxPerPage + 1
		End If
	End If
	If CurrentPage > 1 Then
		If (CurrentPage - 1) * MaxPerPage >= totalPut Then
			CurrentPage = 1
		End If
	End If
	For i = 1 To totalPut
		n=n+1
		If u >= MaxPerPage Then
			Exit For
		ElseIf n > MaxPerPage * (CurrentPage - 1) Then
		Response.Write "            <input type=""radio"" id=""Cpath"" name=""Cpath"" value=""" & i & """" & Check_Object2(rsCountList("Cpath"),i," checked") & ">&nbsp;" & vbCrlf
		For j = 0 To 9
		Response.Write "            <img src=""" & InstallDir & "Countpic/" & i & "/" & j & ".gif"">&nbsp;" & vbCrlf
		Next
		Response.Write "            <br>" & vbCrlf
		u=u+1
		End If
	Next
	Response.Write "            "&ShowPage(strFileName, totalPut, MaxPerPage, CurrentPage, True, True, "个计数器样式", True)
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">计数器数值</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-2"">" & vbCrlf
	Response.Write "            <input type=""number"" min=""0"" id=""Hits"" name=""Hits"" maxlength=""50"" value=""" & rsCountList("Hits") & """ lay-verify=""Hits"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">计数器位数</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <div id=""Style_outer"" ztype=""select"" class=""z-combox"" style=""display:inline-block; *zoom: 1;*display: inline;vertical-align:middle;height:auto;width:auto;position:relative;border:none 0;margin:0;padding:0;white-space: nowrap;"" _style=""width:80px;""><input type=""text"" ztype=""select"" id=""Style"" name=""Style"" tabindex=""-1"" autocomplete=""off"" class=""inputText"" style=""width:80px;position:absolute;z-index:-1;"" value=""" & rsCountList("Style") & """ startvalue=""" & rsCountList("Style") & """/><input type=""text"" id=""Style_textField"" autocomplete=""off"" class=""inputText"" style=""vertical-align:middle; cursor:default;width:80px;"" /><a id=""Style_spinner"" class=""z-combox-spinner"" style=""position:relative; left:-17px; margin-right:-15px; cursor:pointer; width:13px; height:15px;vertical-align:middle;""><b></b></a><div id=""Style_list"" class=""optgroup"" style=""text-align:left;display:none;""><div id=""Style_ul"" style=""left:-1px; width:-1px;""><script>Combox_Style_Init=function(){var _el=Zving.getDom('Style');if(_el._components){return true;}var  _data=[];var  _DataSource;"
	For i=1 To 100
	Response.Write "_data.push(['" & i & "','" & i & "位']);"
	Next
	Response.Write "var combox_Style = new Zving.Selector({el:_el,data:_data,DataSource:_DataSource});};if(Zving.Page.isReady){Combox_Style_Init();}else{Zving.Page.onReady(Combox_Style_Init);}</script></div></div></div>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">风格显示</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-t"">" & vbCrlf
	l=len(rsCountList("Hits"))
	If l>rsCountList("Style") Then
		l=rsCountList("Style")
	End If
	If l<rsCountList("Style") And rsCountList("Style")<>100 Then
		b=rsCountList("Style")-l
	End If
	For p=1 To b
		Response.Write "            <img src='" & InstallDir & "Countpic/" & rsCountList("Cpath") & "/0.gif'>&nbsp;" & vbCrlf
	Next
	For z=1 To l
		If z=1 Then
			q=left(rsCountList("Hits"),z)
		Else
			q=left(rsCountList("Hits"),z)-(left(rsCountList("Hits"),((z-1)))*10)
		End If
		Response.Write "            <img src='" & InstallDir & "Countpic/" & rsCountList("Cpath") & "/" & q & ".gif'>&nbsp;" & vbCrlf
	Next
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <div class=""layui-input-block"">" & vbCrlf
	Response.Write "            <input name=""Cpath2"" type=""hidden"" id=""Cpath2"" value=""" & rsCountList("Cpath") & """>" & vbCrlf
	Response.Write "            <input name=""Action"" type=""hidden"" id=""Action"" value=""SaveModify"">" & vbCrlf
	Response.Write "            <button type=""button"" class=""layui-btn"" accesskey=""s"" lay-submit="""" lay-filter=""submit"">确定[S]</button>" & vbCrlf
	Response.Write "            <button type=""reset"" class=""layui-btn layui-btn-danger"" accesskey=""r"">重置[R]</button>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "</div>" & vbCrlf
	Response.Write "</form>" & vbCrlf
	Response.Write "<script>" & vbCrlf
	Response.Write "layui.use(['form'], function () {" & vbCrlf
	Response.Write "    var form = layui.form;" & vbCrlf
	Response.Write "    //自定义表单验证" & vbCrlf
	Response.Write "    form.verify({" & vbCrlf
	Response.Write "        Hits: function (value, item) {" & vbCrlf
	Response.Write "            if (!value){" & vbCrlf
	Response.Write "                item.focus();" & vbCrlf
	Response.Write "                return ""计数器不能为空！"";" & vbCrlf
	Response.Write "            }" & vbCrlf
	Response.Write "        }," & vbCrlf
	Response.Write "    })" & vbCrLf
	Response.Write "    //提交监听" & vbCrlf
	Response.Write "    form.on('submit(submit)', function (data) {" & vbCrlf
	Response.Write "        loading = layer.load(1, {shade: [0.1,'#fff']});" & vbCrlf
	Response.Write "        $.ajax({" & vbCrLf
	Response.Write "            type: 'post'," & vbCrLf
	Response.Write "            url: '?Action=SaveModify'," & vbCrLf
	Response.Write "            data: data.field," & vbCrLf
	Response.Write "            dataType: 'json'," & vbCrLf
	Response.Write "            success: function(res) {" & vbCrLf
	Response.Write "                layer.close(loading);" & vbCrlf
	Response.Write "                if(res.code > 0){" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 1, time: 1000},function(){" & vbCrlf
	Response.Write "                        location.href = res.url;" & vbCrlf
	Response.Write "                    });" & vbCrlf
	Response.Write "                }else{" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 2, time: 1000});" & vbCrlf
	Response.Write "                }" & vbCrlf
	Response.Write "            }" & vbCrLf
	Response.Write "        });" & vbCrLf
	Response.Write "    });" & vbCrlf
	Response.Write "});" & vbCrlf
	Response.Write "</script>" & vbCrlf
	rsCountList.Close
	Set rsCountList = Nothing
	Response.Write "</body>" & vbCrLf & "</html>"
End Sub

Sub SaveModify()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		Cpath=Request.Form("Cpath")
		Style=Request.Form("Style")
		Hits=Request.Form("Hits")
		If Cpath<>"" Then
			Cpath=Cpath
		Else
			Cpath=Request.Form("Cpath2")
		End If
		If Hits="" Then
			Hits=0
		End If
		Call Exec("","Update ["&Data_Name&"] Set Cpath='" & Cpath & "',Style='" & Style & "',Hits='" & Hits & "' Where ID=1",0)
		Response.Write "{""code"":1,""msg"":""\u4fdd\u5b58\u6210\u529f\uff01"",""url"":""?""}" & vbCrLf
		Response.End()
	End If
End Sub
%>